<?php
/**
 * Created by PhpStorm.
 * User: SnGef
 * Date: 2017/6/26
 * Time: 18:35
 */
global $_W, $_GPC;

$pageid = empty($_GPC['pageid']) ? "" : $_GPC['pageid'];

$page     = intval(trim($_GPC['page'])) ?: '';
$pindex   = max(1, intval($page));
$psize    = 20;
$kw       = empty($_GPC['keyword']) ? "" : $_GPC['keyword'];
$deviceList    = pdo_fetchall("SELECT * FROM " . tablename('xd_device') . " WHERE  device_name LIKE :name ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(
    ':name' => "%{$kw}%"
));

$pagesnum = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('xd_device'));
$total    = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('xd_device') . " WHERE device_name LIKE :name ORDER BY id DESC ", array(
    ':name' => "%{$kw}%"
));

$pager    = pagination($total, $pindex, $psize);
//print_r($_W['uniacid']);exit;
include $this->template('device_list');